package Lee_code;

public class Lee_209 {
    public int minSubArrayLen(int target, int[] nums) {
        int fast=0, slow=0;
        int min_len = 99999;
        int sum=0;
        while(fast< nums.length)
        {
            if(sum<target)
            {
                sum=sum+nums[fast];
                fast++;
            }
            else if (sum>=target)
            {
                int temp_len = fast - slow;
                min_len = Math.min(temp_len, min_len);
                sum = sum - nums[slow];
                slow++;
            }
        }
        if (min_len!=99999)
            return min_len;
        return 0;
    }
}
